/*package com.baizhi.cmfz.aspact;

import com.baizhi.cmfz.annotation.LogAnnotation;
import com.baizhi.cmfz.dao.LogDao;
import com.baizhi.cmfz.entity.Admin;
import com.baizhi.cmfz.entity.Log;
import com.baizhi.cmfz.util.IPKit;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.reflect.MethodSignature;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.lang.reflect.Method;
import java.util.Date;
*//**
 * 增强类，添加注解声明这是一个增强类，并且声明这是一个配置类
 *//*
@Configuration
//@Aspect
public class OldLogAspact {
    //创建日志对象
    private Logger logger = LoggerFactory.getLogger(LogAspact.class);
    @Autowired(required = false)
    private LogDao logDao;

    *//**
     * 写后置增强方法，指定切入点，获取切入节点对象joinPoint
     * 获取这个对象是为了获取到日志内容和类型
     * @param joinPoint
     *//*
    @After("@annotation(com.baizhi.cmfz.annotation.LogAnnotation)")
    public void logAfter(JoinPoint joinPoint) {
        //创建一个日志对象
        Log log = new Log();
        //1 日志信息的采集
        log.setLogDate(new Date());
        //获取放在session中的admin用户id 需要解决如何获取当前请求的session
        ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
        HttpServletRequest request = requestAttributes.getRequest();
        HttpSession session = request.getSession();
        //将获取到的session输出到日志
        logger.debug(session.toString());
        //获取到adminId
        Admin admin = (Admin) session.getAttribute("admin");
        log.setAdmin(admin);

        //获取到访问者的ip 使用工具类获取 也可以直接通过request获取
        String ipAddrByRequest = IPKit.getIpAddrByRequest(request);
        log.setLogIp(ipAddrByRequest);
        //日志信息与类型的获取
        *//*
         * 通过注解的方式传值，需要获取到连接点对象 然后通过连接点对象获取方法签名对象
         * 在然后通过方法签名对象获取方法对象 得到方法的注解
         * *//*
        MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
        Method method = methodSignature.getMethod();
        LogAnnotation annotation = method.getAnnotation(LogAnnotation.class);
        String value = annotation.value();
        String type = annotation.type();
        log.setLogContent(value);
        log.setLogType(type);
        logger.debug(log.toString());
        //将日志记录的对象存入数据库
        logDao.addLog(log);
    }
}*/
